import 'package:equatable/equatable.dart';
import 'package:backend.purchases/domain/entities/app_store_api/app_store_api_purchased_subscription_price_increase_status.dart';

class AppStoreApiPurchasedSubscriptionPriceIncreaseStatusDto extends Equatable {
  const AppStoreApiPurchasedSubscriptionPriceIncreaseStatusDto._internal({
    required this.priceIncreaseStatusCode,
  });

  final int? priceIncreaseStatusCode;

  @override
  List<Object?> get props {
    return [
      priceIncreaseStatusCode,
    ];
  }

  factory AppStoreApiPurchasedSubscriptionPriceIncreaseStatusDto.fromCode(
      int? priceIncreaseStatusCode) {
    return AppStoreApiPurchasedSubscriptionPriceIncreaseStatusDto._internal(
      priceIncreaseStatusCode: priceIncreaseStatusCode,
    );
  }

  AppStoreApiPurchasedSubscriptionPriceIncreaseStatus toEntity() {
    if (priceIncreaseStatusCode == null) {
      return AppStoreApiPurchasedSubscriptionPriceIncreaseStatus.absent;
    }

    if (priceIncreaseStatusCode == 0) {
      return AppStoreApiPurchasedSubscriptionPriceIncreaseStatus.pending;
    }

    if (priceIncreaseStatusCode == 1) {
      return AppStoreApiPurchasedSubscriptionPriceIncreaseStatus.accepted;
    }

    throw UnimplementedError();
  }
}
